using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;

namespace UTorrentLib
{
    public enum TorrentFilePriority
    {
        DO_NOT_DOWNLOAD,
        LOW,
        NORMAL,
        HIGH
    }
    public class UTorrentFile
    {
        private UTorrent m_uParent;
        public String FileName
        {
            get
            {
                return (String)mFile[0];
            }
        }
        public long FileSize
        {
            get
            {
                return (long)mFile[1];
            }
        }
        public long Downloaded
        {
            get
            {
                return (long)mFile[2];
            }
        }
        public int Percent
        {
            get
            {
                return (int)((double)((double)this.Downloaded / (double)this.FileSize) * 100);
            }
        }
        public TorrentFilePriority Priority
        {
            get
            {
                return (TorrentFilePriority)((int)((long)mFile[3]));
            }
        }
        private JavaScriptArray mFile;

        #region Formated Strings for displaying in a GUI
        public String fFileSize
        {
            get
            {
                return DisplayFunctions.FormatSize(this.FileSize);
            }
        }
        public String fDownloaded
        {
            get
            {
                return DisplayFunctions.FormatSize(this.Downloaded);
            }
        }
        public String fPercent
        {
            get
            {
                return this.Percent.ToString() + "%";
            }
        }
        public String fPriority
        {
            get
            {
                switch (this.Priority)
                {
                    case TorrentFilePriority.DO_NOT_DOWNLOAD:
                        return "Don't download";
                    case TorrentFilePriority.HIGH:
                        return "High";
                    case TorrentFilePriority.LOW:
                        return "Low";
                    case TorrentFilePriority.NORMAL:
                        return "Normal";
                }
                return "";
            }
        }
        #endregion

        public UTorrentFile(JavaScriptArray mFile, UTorrent parent)
        {
            this.mFile = mFile;
            this.m_uParent = parent;
        }

       /* public void StartDownload(object sender, EventArgs e)
        {

            FileDownload fd = new FileDownload(this);

            fd.Start();
            Program.localDownloads.Add(fd);
        }*/

    }
}
